home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  10.4 KB  |  364 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __EVENTS__
  19. #define __EVENTS__
  20.  
  21. #ifndef __OSUTILS__
  22. #include <OSUtils.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27. #ifndef __MACTYPES__
  28. #include <MacTypes.h>
  29. #endif
  30.  
  31. #if !TARGET_OS_MAC
  32. #ifndef __ENDIAN__
  33. #include <Endian.h>
  34. #endif
  35. #endif  /*  !TARGET_OS_MAC */
  36.  
  37.  
  38.  
  39. #if PRAGMA_ONCE
  40. #pragma once
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT
  48. #pragma import on
  49. #endif
  50.  
  51. #if PRAGMA_STRUCT_ALIGN
  52.     #pragma options align=mac68k
  53. #elif PRAGMA_STRUCT_PACKPUSH
  54.     #pragma pack(push, 2)
  55. #elif PRAGMA_STRUCT_PACK
  56.     #pragma pack(2)
  57. #endif
  58.  
  59. typedef UInt16                             EventKind;
  60. typedef UInt16                             EventMask;
  61.  
  62. enum {
  63.     nullEvent                    = 0,
  64.     mouseDown                    = 1,
  65.     mouseUp                        = 2,
  66.     keyDown                        = 3,
  67.     keyUp                        = 4,
  68.     autoKey                        = 5,
  69.     updateEvt                    = 6,
  70.     diskEvt                        = 7,
  71.     activateEvt                    = 8,
  72.     osEvt                        = 15,
  73.     kHighLevelEvent                = 23
  74. };
  75.  
  76.  
  77. enum {
  78.     mDownMask                    = 1 << mouseDown,                /* mouse button pressed*/
  79.     mUpMask                        = 1 << mouseUp,                    /* mouse button released*/
  80.     keyDownMask                    = 1 << keyDown,                    /* key pressed*/
  81.     keyUpMask                    = 1 << keyUp,                    /* key released*/
  82.     autoKeyMask                    = 1 << autoKey,                    /* key repeatedly held down*/
  83.     updateMask                    = 1 << updateEvt,                /* window needs updating*/
  84.     diskMask                    = 1 << diskEvt,                    /* disk inserted*/
  85.     activMask                    = 1 << activateEvt,                /* activate/deactivate window*/
  86.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents)*/
  87.     osMask                        = 1 << osEvt,                    /* operating system events (suspend, resume)*/
  88.     everyEvent                    = 0xFFFF                        /* all of the above*/
  89. };
  90.  
  91.  
  92. enum {
  93.     charCodeMask                = 0x000000FF,
  94.     keyCodeMask                    = 0x0000FF00,
  95.     adbAddrMask                    = 0x00FF0000,
  96.     osEvtMessageMask            = (long)0xFF000000
  97. };
  98.  
  99.  
  100. enum {
  101.                                                                 /* OS event messages.  Event (sub)code is in the high byte of the message field.*/
  102.     mouseMovedMessage            = 0x00FA,
  103.     suspendResumeMessage        = 0x0001
  104. };
  105.  
  106.  
  107. enum {
  108.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend*/
  109.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change*/
  110. };
  111.  
  112.  
  113. typedef UInt16                             EventModifiers;
  114.  
  115. enum {
  116.                                                                 /* modifiers */
  117.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown)*/
  118.     btnStateBit                    = 7,                            /* state of button?*/
  119.     cmdKeyBit                    = 8,                            /* command key down?*/
  120.     shiftKeyBit                    = 9,                            /* shift key down?*/
  121.     alphaLockBit                = 10,                            /* alpha lock down?*/
  122.     optionKeyBit                = 11,                            /* option key down?*/
  123.     controlKeyBit                = 12,                            /* control key down?*/
  124.     rightShiftKeyBit            = 13,                            /* right shift key down?*/
  125.     rightOptionKeyBit            = 14,                            /* right Option key down?*/
  126.     rightControlKeyBit            = 15                            /* right Control key down?*/
  127. };
  128.  
  129.  
  130. enum {
  131.     activeFlag                    = 1 << activeFlagBit,
  132.     btnState                    = 1 << btnStateBit,
  133.     cmdKey                        = 1 << cmdKeyBit,
  134.     shiftKey                    = 1 << shiftKeyBit,
  135.     alphaLock                    = 1 << alphaLockBit,
  136.     optionKey                    = 1 << optionKeyBit,
  137.     controlKey                    = 1 << controlKeyBit,
  138.     rightShiftKey                = 1 << rightShiftKeyBit,
  139.     rightOptionKey                = 1 << rightOptionKeyBit,
  140.     rightControlKey                = 1 << rightControlKeyBit
  141. };
  142.  
  143.  
  144. enum {
  145.     kNullCharCode                = 0,
  146.     kHomeCharCode                = 1,
  147.     kEnterCharCode                = 3,
  148.     kEndCharCode                = 4,
  149.     kHelpCharCode                = 5,
  150.     kBellCharCode                = 7,
  151.     kBackspaceCharCode            = 8,
  152.     kTabCharCode                = 9,
  153.     kLineFeedCharCode            = 10,
  154.     kVerticalTabCharCode        = 11,
  155.     kPageUpCharCode                = 11,
  156.     kFormFeedCharCode            = 12,
  157.     kPageDownCharCode            = 12,
  158.     kReturnCharCode                = 13,
  159.     kFunctionKeyCharCode        = 16,
  160.     kEscapeCharCode                = 27,
  161.     kClearCharCode                = 27,
  162.     kLeftArrowCharCode            = 28,
  163.     kRightArrowCharCode            = 29,
  164.     kUpArrowCharCode            = 30,
  165.     kDownArrowCharCode            = 31,
  166.     kDeleteCharCode                = 127,
  167.     kNonBreakingSpaceCharCode    = 202
  168. };
  169.  
  170.  
  171. struct EventRecord {
  172.     EventKind                         what;
  173.     UInt32                             message;
  174.     UInt32                             when;
  175.     Point                             where;
  176.     EventModifiers                     modifiers;
  177. };
  178. typedef struct EventRecord                EventRecord;
  179.  
  180. typedef CALLBACK_API( void , FKEYProcPtr )(void );
  181. typedef STACK_UPP_TYPE(FKEYProcPtr)                             FKEYUPP;
  182. enum { uppFKEYProcInfo = 0x00000000 };                             /* pascal no_return_value Func() */
  183. #define NewFKEYProc(userRoutine)                                 (FKEYUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  184. #define CallFKEYProc(userRoutine)                                 CALL_ZERO_PARAMETER_UPP((userRoutine), uppFKEYProcInfo)
  185. EXTERN_API( void )
  186. GetMouse                        (Point *                mouseLoc)                            ONEWORDINLINE(0xA972);
  187.  
  188. EXTERN_API( Boolean )
  189. Button                            (void)                                                        ONEWORDINLINE(0xA974);
  190.  
  191. EXTERN_API( Boolean )
  192. StillDown                        (void)                                                        ONEWORDINLINE(0xA973);
  193.  
  194. EXTERN_API( Boolean )
  195. WaitMouseUp                        (void)                                                        ONEWORDINLINE(0xA977);
  196.  
  197. EXTERN_API( UInt32 )
  198. TickCount                        (void)                                                        ONEWORDINLINE(0xA975);
  199.  
  200. EXTERN_API( UInt32 )
  201. KeyTranslate                    (const void *            transData,
  202.                                  UInt16                 keycode,
  203.                                  UInt32 *                state)                                ONEWORDINLINE(0xA9C3);
  204.  
  205. EXTERN_API( UInt32 )
  206. GetCaretTime                    (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F4);
  207.  
  208.  
  209. /* 
  210.     QuickTime 3.0 supports GetKeys() on unix and win32
  211.     But, on little endian machines you will have to be
  212.     careful about bit numberings and/or use a KeyMapByteArray
  213.     instead.
  214. */
  215. #if TARGET_OS_MAC
  216.  
  217. typedef long                             KeyMap[4];
  218. #else
  219. typedef BigEndianLong                     KeyMap[4];
  220. #endif  /* TARGET_OS_MAC */
  221.  
  222. typedef UInt8                             KeyMapByteArray[16];
  223. EXTERN_API( void )
  224. GetKeys                            (KeyMap                 theKeys)                            ONEWORDINLINE(0xA976);
  225.  
  226.  
  227.  
  228. /* Obsolete event types & masks */
  229.  
  230. enum {
  231.     networkEvt                    = 10,
  232.     driverEvt                    = 11,
  233.     app1Evt                        = 12,
  234.     app2Evt                        = 13,
  235.     app3Evt                        = 14,
  236.     app4Evt                        = 15,
  237.     networkMask                    = 0x0400,
  238.     driverMask                    = 0x0800,
  239.     app1Mask                    = 0x1000,
  240.     app2Mask                    = 0x2000,
  241.     app3Mask                    = 0x4000,
  242.     app4Mask                    = 0x8000
  243. };
  244.  
  245.  
  246. struct EvQEl {
  247.     QElemPtr                         qLink;
  248.     SInt16                             qType;
  249.     EventKind                         evtQWhat;                    /* this part is identical to the EventRecord as defined above */
  250.     UInt32                             evtQMessage;
  251.     UInt32                             evtQWhen;
  252.     Point                             evtQWhere;
  253.     EventModifiers                     evtQModifiers;
  254. };
  255. typedef struct EvQEl                    EvQEl;
  256. typedef EvQEl *                            EvQElPtr;
  257. typedef CALLBACK_API( void , GetNextEventFilterProcPtr )(EventRecord *theEvent, Boolean *result);
  258. /*
  259.     WARNING: GetNextEventFilterProcPtr uses register based parameters under classic 68k
  260.              and cannot be written in a high-level language without 
  261.              the help of mixed mode or assembly glue.
  262. */
  263. typedef REGISTER_UPP_TYPE(GetNextEventFilterProcPtr)             GetNextEventFilterUPP;
  264. enum { uppGetNextEventFilterProcInfo = 0x000000BF };             /* SPECIAL_CASE_PROCINFO(11) */
  265. #define NewGetNextEventFilterProc(userRoutine)                     (GetNextEventFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  266. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  267.     /* CallGetNextEventFilterProc can't be called from classic 68k without glue code */
  268. #else
  269.     #define CallGetNextEventFilterProc(userRoutine, theEvent, result)  CALL_TWO_PARAMETER_UPP((userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  270. #endif
  271.  
  272. typedef GetNextEventFilterUPP             GNEFilterUPP;
  273. EXTERN_API( QHdrPtr )
  274. GetEvQHdr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  275.  
  276. EXTERN_API( UInt32 )
  277. GetDblTime                        (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F0);
  278.  
  279. EXTERN_API( void )
  280. SetEventMask                    (EventMask                 value)                                TWOWORDINLINE(0x31DF, 0x0144);
  281.  
  282.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  283.                                                                                             #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  284.                                                                                             #endif
  285. EXTERN_API( OSErr )
  286. PPostEvent                        (EventKind                 eventCode,
  287.                                  UInt32                 eventMsg,
  288.                                  EvQElPtr *                qEl)                                TWOWORDINLINE(0xA12F, 0x2288);
  289.  
  290. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  291. EXTERN_API( Boolean )
  292. GetNextEvent                    (EventMask                 eventMask,
  293.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA970);
  294.  
  295. EXTERN_API( Boolean )
  296. WaitNextEvent                    (EventMask                 eventMask,
  297.                                  EventRecord *            theEvent,
  298.                                  UInt32                 sleep,
  299.                                  RgnHandle                 mouseRgn)                            ONEWORDINLINE(0xA860);
  300.  
  301. EXTERN_API( Boolean )
  302. EventAvail                        (EventMask                 eventMask,
  303.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA971);
  304.  
  305.  
  306.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  307.                                                                                             #pragma parameter __D0 PostEvent(__A0, __D0)
  308.                                                                                             #endif
  309. EXTERN_API( OSErr )
  310. PostEvent                        (EventKind                 eventNum,
  311.                                  UInt32                 eventMsg)                            ONEWORDINLINE(0xA02F);
  312.  
  313.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  314.                                                                                             #pragma parameter __D0 OSEventAvail(__D0, __A0)
  315.                                                                                             #endif
  316. EXTERN_API( Boolean )
  317. OSEventAvail                    (EventMask                 mask,
  318.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA030, 0x5240);
  319.  
  320.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  321.                                                                                             #pragma parameter __D0 GetOSEvent(__D0, __A0)
  322.                                                                                             #endif
  323. EXTERN_API( Boolean )
  324. GetOSEvent                        (EventMask                 mask,
  325.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA031, 0x5240);
  326.  
  327. EXTERN_API( void )
  328. FlushEvents                        (EventMask                 whichMask,
  329.                                  EventMask                 stopMask)                            TWOWORDINLINE(0x201F, 0xA032);
  330.  
  331. EXTERN_API( void )
  332. SystemClick                        (const EventRecord *    theEvent,
  333.                                  WindowPtr                 theWindow)                            ONEWORDINLINE(0xA9B3);
  334.  
  335. EXTERN_API( void )
  336. SystemTask                        (void)                                                        ONEWORDINLINE(0xA9B4);
  337.  
  338. EXTERN_API( Boolean )
  339. SystemEvent                        (const EventRecord *    theEvent)                            ONEWORDINLINE(0xA9B2);
  340.  
  341.  
  342.  
  343.  
  344. #if PRAGMA_STRUCT_ALIGN
  345.     #pragma options align=reset
  346. #elif PRAGMA_STRUCT_PACKPUSH
  347.     #pragma pack(pop)
  348. #elif PRAGMA_STRUCT_PACK
  349.     #pragma pack()
  350. #endif
  351.  
  352. #ifdef PRAGMA_IMPORT_OFF
  353. #pragma import off
  354. #elif PRAGMA_IMPORT
  355. #pragma import reset
  356. #endif
  357.  
  358. #ifdef __cplusplus
  359. }
  360. #endif
  361.  
  362. #endif /* __EVENTS__ */
  363.  
  364.